-- Handle the A key.
function HandleA()
end

function HandleClosed()
end


-- Main startup for XO.
function XO()
	-- Load the fonts used in the game.
	WindowManager.Instance:LoadFont( "Fonts/Delicious-Roman.otf" )
	WindowManager.Instance:LoadFont( "Fonts/Delicious-Italic.otf" )
	WindowManager.Instance:LoadFont( "Fonts/Delicious-Bold.otf" )
	WindowManager.Instance:LoadFont( "Fonts/Delicious-BoldItalic.otf" )

	-- Testing initial conversion to lua driven start.
	local mode	=	VideoMode:GetDesktopMode()
	if( mode~=nil ) then
		print( 'Desktop: ' .. tostring( mode.Width ) .. 'x' .. tostring( mode.Height ) .. ' bpp: ' .. tostring( mode.BPP ) )
	end
	local fsmodes	=	VideoMode:GetFullscreenModes()
	if( mode~=nil ) then
		print( 'got fullscreen modes' )
	end

	-- Eventual intentions:
	--	1.	Load all game scripts.
	--	2.	Ask the config system for screen count if this is a multi-window
	--		application.
	--		a.	Create each window.
	--		b.	Position and size each window according to config system settings.
	--		c.	Load documents etc on each window.
	--	3.	Ask config system for clock settings, i.e. time of game, speed, stepping
	--		whatever is proper.  Set the clock.
	--	4.	Register any game updates as is proper.
	--	5.	Done.. ?

	-- Eventual outline.
	-- Create the game window.  Configures automatically based on name.
	-- Decide the best method of passing in information.
--	local	window	=	WindowManager.Instance:CreateWindow( 'XO' )

--	window:BindKey( Keyboard.A, KeyModifiers.Any, HandleA )

--	window:BindEvent( Event.Closed, HandleClosed )


	-- Load the UI.
	local	doc		=	WindowManager.Instance:LoadDocument( "top_bar.rml" )
	doc:Show( WindowManager.None )

	-- Register the game update function.
	Application.Instance:RegisterUpdate( "GameUpdate", 0,
		coroutine.wrap(
			function()
				local	count	=	0
				while true do
--					print( "Loopsy: " .. count )
					count = count + 1
					if count < 100 then
						coroutine.yield()
					else
						break
					end
				end

				-- Clean up and bail.
				Application.Instance:UnregisterUpdate( "GameUpdate", 0 )
			end
		)
	)
end
